/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 邓大帅
 * Date: 2022-12-14
 * Time: 13:58
 */
public class Hanoi {
    public static void hanoi(int n, char pos1, char pos2, char pos3) {
        if(n == 1) {
            move(pos1,pos3);
            return;
        }
        hanoi(n-1,pos1,pos3,pos2);
        move(pos1,pos3);
        hanoi(n-1,pos2,pos1,pos3);
    }
    public static void move(char posStart, char posEnd) {
        System.out.println(posStart + "->" + posEnd);
    }
    public static void main(String[] args) {
        hanoi(1, 'a', 'b', 'c');
        System.out.println("==============");
        hanoi(2, 'a', 'b', 'c');
        System.out.println("==============");
        hanoi(3, 'a', 'b', 'c');

    }
}
